//
//  PerformanceRegisterViewController.m
//  WorkingResult
//
//  Created by 河野 智遵 on 11/09/03.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "PerformanceRegisterViewController.h"


@implementation PerformanceRegisterViewController

@synthesize dateSelectActionTarget;
@synthesize dateSelectAction;

- (NSString*)formatDate:(NSDate*)date
{
    NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease];
    [formatter setDateFormat:@"yyyy/M/d"];
    return [formatter stringFromDate:date];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    dateSelect_ = [[DateSelectViewController alloc] init];
    
    UIBarButtonItem* item = [[UIBarButtonItem alloc] initWithTitle:@"登録日の変更" style:UIBarButtonItemStyleBordered target:self action:@selector(onSelectDate)];
    self.view.backgroundColor = [UIColor blackColor];
    
    self.title = [self formatDate:[NSDate date]];
    
    [self.navigationItem setLeftBarButtonItem:item animated:YES];
    
    currentDate_ = [[NSDate date] retain];
    self.title = [self formatDate:currentDate_];
}

- (void)setCurrentDate:(NSDate*)currentDate
{
    [currentDate_ autorelease];
    currentDate_ = [currentDate retain];
    self.title = [self formatDate:currentDate_];
    NSLog(@"%@", [self formatDate:currentDate_]);
}

- (NSDate*)getCurrentDate
{
    return currentDate_;
}

- (void)onSelectDate
{
    [dateSelectActionTarget performSelector:dateSelectAction];
}

- (void)dealloc
{
    [currentDate_ release];
    [dateSelect_ release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView
{
}
*/

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
